<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#" class="back" onclick="history.go(-1)"/>Visualizar Portaria</h2>
        </ui:define>

        <ui:define name="body">

            <p:panel styleClass="container_24 clearfix">
                <div class="buttonAction" style="float: right">
                    <p:button value="Editar" href="editarportaria.xhtml?ePortaria=#{managerPesquisarPortaria.portariaVisualizar.id}" 
                              icon="ui-icon-pencil" styleClass="ui-priority-primary"/>
                </div>
            </p:panel>

            <h:form id="portariaForm" enctype="multipart/form-data">            
                <p:messages id="messages" closable="true" showDetail="false" autoUpdate="true"  />
                <p>
                    <p:panel id="portariaPanel" styleClass="container_24 clearfix" >

                        <p:outputLabel value="Tipo Portaria:" styleClass="grid_3 tipoProcessoLabel" 
                                       for="tipoPortariaInputText" />
                        <p:inputText id="tipoPortariaInputText" styleClass="grid_8"
                                     readonly="true" value="#{managerPesquisarPortaria.portariaVisualizar.tipoPortaria.nome}" />

                        <p:outputLabel value="Data:" styleClass="grid_4" for="dataCalendar" />
                        <div class="grid_9">
                            <p:inputText id="dataCalendar" value="#{managerPesquisarPortaria.dataPortaria()}"
                                         readonly="true" style="width: 89.5%" />
                        </div>
                        <div class="clear"/>

                        <p:outputLabel value="Secretaria:" styleClass="grid_3" for="secretariaInputText"/>
                        <p:inputText id="secretariaInputText" styleClass="grid_20" 
                                     value="#{managerPesquisarPortaria.secretariaVisualizar.nome}" readonly="true"/>
                        <div class="clear" />

                        <p:outputLabel value="Assunto:" styleClass="grid_3" for="assuntoInputTextarea" />
                        <p:inputTextarea id="assuntoInputTextarea" styleClass="grid_20" readonly="true"
                                         value="#{managerPesquisarPortaria.portariaVisualizar.assunto}" />

                        <br/>
                    </p:panel>

                    <h2>Pessoa</h2>

                    <p:panel id="clientePanel" styleClass="container_24 clearfix">

                        <p:outputLabel value="#{managerPesquisarPortaria.pessoaFisicaVisualizar ? 'CPF:' : 'CNPJ:'}" 
                                       styleClass="grid_3" for="cpfCnpjInputMask" />
                        <p:inputMask id="cpfCnpjInputMask"
                                     value="#{managerPesquisarPortaria.pessoaFisicaVisualizar ? managerPesquisarPortaria.pessoaVisualizar.cpf : managerPesquisarPortaria.pessoaVisualizar.cnpj}" 
                                     styleClass="grid_8" readonly="true"
                                     mask="#{managerPesquisarPortaria.pessoaFisicaVisualizar ? '999.999.999-99' : '99.999.999/9999-99' }"
                                     autocomplete="false"/>
                        <div class="clear"/>

                        <p:outputLabel value="#{managerPesquisarPortaria.pessoaFisicaVisualizar ? 'Nome:' : 'Nome Fantasia:'}" 
                                       styleClass="grid_3 #{managerPesquisarPortaria.pessoaFisicaVisualizar ? '' : 'nomeFantasiaLabel'}" 
                                       for="nomeInputText" />
                        <p:inputText id="nomeInputText" readonly="true"
                                     value="#{managerPesquisarPortaria.pessoaFisicaVisualizar ? managerPesquisarPortaria.pessoaVisualizar.nome : managerPesquisarPortaria.pessoaVisualizar.nomeFantasia}" 
                                     styleClass="grid_20" />
                        <div class="#{managerPesquisarPortaria.pessoaFisicaVisualizar ? 'clear' : ''}" />

                        <p:outputLabel value="Nome da Mãe:" styleClass="grid_3" 
                                       for="nomeMaeInputText" rendered="#{managerPesquisarPortaria.pessoaFisicaVisualizar}"/>
                        <p:inputText id="nomeMaeInputText" 
                                     value="#{managerPesquisarPortaria.pessoaVisualizar.nomeMae}" 
                                     readonly="true" rendered="#{managerPesquisarPortaria.pessoaFisicaVisualizar}"
                                     styleClass="grid_20" />
                        <div class="#{managerPesquisarPortaria.pessoaFisicaVisualizar ? 'clear' : ''}" />

                        <p:outputLabel value="RG:" styleClass="grid_3" for="rgInputText"
                                       rendered="#{managerPesquisarPortaria.pessoaFisicaVisualizar}"/> 
                        <p:inputText id="rgInputText" styleClass="grid_8" 
                                     value="#{managerPesquisarPortaria.pessoaVisualizar.rg}"
                                     readonly="true" rendered="#{managerPesquisarPortaria.pessoaFisicaVisualizar}"/>

                        <p:outputLabel value="Data de Nascimento:" styleClass="grid_4" 
                                       for="dataNascInputText" rendered="#{managerPesquisarPortaria.pessoaFisicaVisualizar}"/>
                        <div class="grid_9">
                            <p:inputText id="dataNascInputText" value="#{managerPesquisarPortaria.dataNascimentoVisualizar()}"
                                         style="width: 90%" readonly="true"
                                         rendered="#{managerPesquisarPortaria.pessoaFisicaVisualizar and managerPesquisarPortaria.pessoaVisualizar.id ne null}" />
                        </div>
                    </p:panel>

                    <br/>
                    <h2>Anexos</h2>

                    <p:panel id="processoCamposPanel" styleClass="container_24 clearfix" >

                        <p:panel id="anexosPanel" styleClass="container_24 clearfix arquivosAnexadosPanel" header="Arquivos anexados">

                            <ui:repeat value="#{managerPesquisarPortaria.anexosVisualizar}" var="a">
                                <p:panel styleClass="grid_5">
                                    <h:outputLink  
                                        value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.tipo}"  target="_blank" >

                                        <div style="width: 100%;" class="grid_4">

                                            <p:graphicImage id="anexoImagem"
                                                            styleClass="image grid_3" rendered="#{a.tipo ne 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;"
                                                            url="show/?annex=#{a.url.concat('thumbnail.').concat(a.nome)}" />

                                            <p:graphicImage id="anexoPdf"
                                                            styleClass="image grid_3" rendered="#{a.tipo eq 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;" 
                                                            url="media/images/pdf.jpeg" />

                                            <div class="clear"/>
                                            <p:outputLabel  value="#{managerPesquisarPortaria.nomeAnexo(a)}" 
                                                            for="anexoImagem"
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.tipo ne 'application/pdf'}"/>

                                            <p:outputLabel for="anexoPdf"
                                                           value="#{managerPesquisarPortaria.nomeAnexoPdf(a)}" 
                                                           style="margin-left:1%; width: 100px;" rendered="#{a.tipo eq 'application/pdf'}"/>
                                        </div>
                                        <f:param name="annex" value="#{a.url.concat(a.nome)}"/>
                                    </h:outputLink>
                                </p:panel>
                            </ui:repeat>
                        </p:panel>
                        <hr style="margin-top: -10px"/>
                        <div class="clear" />
                    </p:panel>

                    <div class="buttonAction">
                        <p:button value="Voltar" icon="ui-icon-circle-arrow-w"
                                  href="pesquisarportaria.xhtml" />
                    </div>
                </p>
            </h:form>

        </ui:define>
    </ui:composition>
</html>


